import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 订单模块-分享
 */
@Entity('order_share')
export class OrderShareEntity extends BaseEntity {
  // 订单ID
  @Column({ comment: '系统订单ID', nullable: true })
  sysOrderId: number;

  @Index({ unique: true })
  @Column({ comment: '订单号', length: 50 })
  orderNo: string;

  // 分账状态
  @Column({
    comment: '分账状态',
    dict: ['待分账', '已分账', '分账失败', '已退款'],
    default: 0,
  })
  shareStatus: number;

  // 分账金额
  @Column({ comment: '分账金额', type: 'decimal', precision: 10, scale: 2 })
  shareAmount: number;

  @Column({ comment: '备注', nullable: true, type: 'text' })
  remark: string;

  // 添加微信支付相关字段
  @Column({ comment: '微信支付商户号', nullable: true, length: 32 })
  mchId: string;

  @Column({ comment: '微信支付订单号', nullable: true, length: 32 })
  transactionId: string;

  @Column({ comment: '分账接收方列表', type: 'json', nullable: true })
  receiverList:   Array<{
    description: string;
    type: string;
    account: string;
    result: string;
    fail_reason: string;
    create_time: string;
    finish_time: string;
    detail_id: string;
  }>;

  // 分账详情
  @Column({ comment: '分账详情', type: 'json', nullable: true })
  shareDetail: any;

  // 回调内容
  @Column({ comment: '回调内容', type: 'json', nullable: true })
  callbackContent: any;
}
